package com.bw.gmallbi.mapper;

import com.bw.gmallbi.bean.TimeData;
import com.bw.gmallbi.bean.VisitorStats;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface VisitorStatsMapper {

    @Select("select is_new,sum(uv_ct) uv_ct,sum(pv_ct) pv_ct,sum(sv_ct) sv_ct,sum(uj_ct) uj_ct,sum(dur_sum) dur_sum from visitor_stats_2105b " +
            "where toYYYYMMDD(stt)=#{date} group by is_new")
    public List<VisitorStats> selectVisitorStats(@Param("date") Integer date);

    @Select("select toHour(stt) hr,sum(uv_ct) uv_ct,sum(pv_ct) pv_ct,sum(if(is_new='1',visitor_stats_2105b.uv_ct,0)) new_uv " +
            "from visitor_stats_2105b where toYYYYMMDD(stt)=#{date} group by hr")
    List<VisitorStats> selectVisitorStatsByHr(Integer date);

    @Select("select formatDateTime(toDateTime(stt),'%Y-%m-%d %H') t,sum(uv_ct) from visitor_stats_2105b  group by formatDateTime(toDateTime(stt),'%Y-%m-%d %H')")
    List<TimeData> selectVisitorByH();
}
